declare global {
    interface RouterMeta {
        title: string;
    }
    interface Router {
        path: string;
        name: string;
        icon?: string;
        permission?: string;
        meta?: RouterMeta;
        component: any;
        children?: Array<Router>;
    }
    interface System {
        import(request: string): Promise<any>
    }
    var System: System
}
import login from '../views/login.vue'
import home from '../views/home/home.vue'
import main from '../views/main.vue'

const isProd = process.env.NODE_ENV === 'production'

export const locking = {
    path: '/locking',
    name: 'locking',
    component: () => import('../components/lockscreen/components/locking-page.vue')
};
export const loginRouter: Router = {
    path: '/',
    name: 'login',
    meta: {
        title: 'LogIn'
    },
    component: () => import('../views/login.vue')
};
export const otherRouters: Router = {
    path: '/main',
    name: 'main',
    meta: { title: 'ManageMenu' },
    component: main,
    children: [
        { path: 'home', meta: { title: 'HomePage' }, name: 'home', component: () => import('../views/home/home.vue') },
        { path: 'error-403', meta: { title: '无权限访问' }, name: 'error-403', component: () => import('../views/home/error-403.vue') },
    ]
}

export const appRouters: Array<Router> = [
    {
        path: '/hesuan',
        name: 'hesuan',
        meta: { title: '核酸检测' },
        icon: '&#xf255;',
        component: main,
        children: [
            { 
                path: 'luru', 
                meta: { title: '检测录入' }, 
                name: 'hesuanLuru', 
                component: () => import('../views/hesuan/luru/index.vue') 
            },
            { 
                path: 'jieguo', 
                meta: { title: '检测结果统计' }, 
                name: 'hesuanJieguo', 
                component: () => import('../views/hesuan/jieguo/index.vue') 
            },
	    ]
    },
    {
        path: '/caiwu',
        name: 'caiwu',
        meta: { title: '财务结算' },
        icon: '&#xf255;',
        component: main,
        children: [
            { 
                path: 'xiaofei', 
                meta: { title: '预约核酸消费明细报表' }, 
                name: 'caiwuXiaofei', 
                component: () => import('../views/caiwu/xiaofei/index.vue') 
            },
            { 
                path: 'jiesuan', 
                meta: { title: '预约核酸结算统计报表' }, 
                name: 'caiwuJiesuan', 
                component: () => import('../views/caiwu/jiesuan/index.vue') 
            },
            { 
                path: 'tuikuan', 
                meta: { title: '核酸退款结算统计报表' }, 
                name: 'caiwuTuikuan', 
                component: () => import('../views/caiwu/tuikuan/index.vue') 
            },
	    ]
    },
]
export const routers = [
    loginRouter,
    locking,
    ...appRouters,
    otherRouters
];

// if (process.env.NODE_ENV != 'production') {
//     let arr = []
//     routers.forEach((r) => {
//         arr.push({
//             title: (r['meta'] as any || {}).title,
//             permission: r['permission'],
//         })

//         r['children'] && (r['children'] as any).forEach((rr) => {
//             arr.push({
//                 title: (rr['meta'] as any || {}).title,
//                 permission: rr['permission'],
//             })
//         })
//     })

//     console.table(arr)
// }